package route

import (
	"chitchat_http/common"
	"chitchat_http/controller"
	"chitchat_http/controller_admin"
	"github.com/doujunyu/gogo/gogo"
	"github.com/doujunyu/gogo/job"
)

func Route(r *gogo.Centre) {
	//跨域
	r.Middleware = append(r.Middleware, common.CrossDomain)
	r.Middleware = append(r.Middleware, common.TokenInput)
	//用户--------------------------------------------------------------------------------------------------------------+
	//账号登录
	r.POST("/LoginByUsername", controller.UserByLoginToUsername)
	//邮箱登录
	r.POST("/LoginByEmail", controller.UserByLoginToEmail)
	//手机号登录
	r.POST("/LoginByMobile", controller.UserByLoginToMobile)
	//账号注册
	r.POST("/RegisterByUsername", controller.UserByRegisterToUsername)
	//个人中心
	r.GET("/MySelf", controller.CheckToken, controller.UserByInfo)
	//个人信息
	r.GET("/UserByInfo", controller.CheckToken, controller.UserByInfo)
	//个人信息更改
	r.POST("/UserByChangeInfo", controller.CheckToken, controller.UserByChangeInfo)
	//修改密码
	r.POST("/UserByChangePassword", controller.CheckToken, controller.UserByChangePassword)
	//首页
	r.GET("/Index", controller.Index)

	//发布动态
	r.POST("/BbsByRelease", controller.CheckToken, controller.BbsByRelease)
	//动态删除
	r.POST("/BbsByDelete", controller.CheckToken, controller.BbsByDelete)
	//动态点赞+1
	r.POST("/BbsByPraiseInc", controller.CheckToken, controller.BbsByPraiseInc)
	//动态点赞-1
	r.POST("/BbsByPraiseDec", controller.CheckToken, controller.BbsByPraiseDec)
	//评论回复
	r.POST("/BbsDiscussByReply", controller.CheckToken, controller.BbsDiscussByReply)
	//删除评论
	r.POST("/BbsDiscussByDelete", controller.CheckToken, controller.BbsDiscussByDelete)
	//动态评论点赞+1
	r.POST("/BbsDiscussByPraiseInc", controller.CheckToken, controller.BbsDiscussByPraiseInc)
	//动态评论点赞-1
	r.POST("/BbsDiscussByPraiseDec", controller.CheckToken, controller.BbsDiscussByPraiseDec)
	//动态列表
	r.GET("/BbsByList", controller.CheckToken, controller.BbsByList)
	//动态详情
	r.GET("/BbsByInfo", controller.CheckToken, controller.BbsByInfo)
	//动态一级列表
	//r.GET("/BbsDiscussByOneLevelList",controller.CheckToken,controller.BbsDiscussByOneLevelList)
	////动态二级级列表
	//r.GET("/BbsDiscussByTwoLevelList",controller.CheckToken,controller.BbsDiscussByTwoLevelList)
	//动态评论
	r.GET("/BbsDiscussByList", controller.CheckToken, controller.BbsDiscussByList)

	//聊天列表
	r.GET("/ChatByList", controller.CheckToken, controller.ChatByList)
	//搜索好友
	r.GET("/ChatBySearchFriend", controller.CheckToken, controller.ChatBySearchFriend)
	//搜索群组
	r.GET("/ChatBySearchGroup", controller.CheckToken, controller.ChatBySearchGroup)
	//申请加好友
	r.POST("/ChatByApplyFriendOrApplyGroup", controller.CheckToken, controller.ChatByApplyFriendOrApplyGroup)
	//申请列表
	r.GET("/ChatByApplyList", controller.CheckToken, controller.ChatByApplyList)
	//操作申请信息
	r.POST("/ChatByApplyCheck", controller.CheckToken, controller.ChatByApplyCheck)
	//好友列表
	r.GET("/ChatByFriendList", controller.CheckToken, controller.ChatByFriendList)
	//好友列表v2
	r.GET("/ChatByFriendListV2", controller.CheckToken, controller.ChatByFriendListV2)
	//解除好友关系
	r.POST("/ChatByFriendRemove", controller.CheckToken, controller.ChatByFriendRemove)
	//发送消息
	r.POST("/ChatBySendMessage", controller.CheckToken, controller.ChatBySendMessage)
	//创建群组
	r.POST("/ChatByCreateGroup", controller.CheckToken, controller.ChatByCreateGroup)
	//群组列表
	r.GET("/ChatByGroupList", controller.CheckToken, controller.ChatByGroupList)
	//群组成员
	r.GET("/ChatByGroupInfo", controller.CheckToken, controller.ChatByGroupInfo)
	//解散群组
	r.POST("/ChatByCreateGroupDelete", controller.CheckToken, controller.ChatByCreateGroupDelete)
	//退出群组
	r.POST("/ChatByCreateGroupExit", controller.CheckToken, controller.ChatByCreateGroupExit)
	//消除接收到得消息
	r.POST("/ChatByCleanMessage", controller.CheckToken, controller.ChatByCleanMessage)
	//消息置顶
	r.POST("/ChatByMessageIsTopYes", controller.CheckToken, controller.ChatByMessageIsTopYes)
	//消息置顶取消
	r.POST("/ChatByMessageIsTopNo", controller.CheckToken, controller.ChatByMessageIsTopNo)
	//聊天记录列表
	r.GET("/ChatByMessageList", controller.CheckToken, controller.ChatByMessageList)

	//音乐列表
	r.GET("/MusicByList", controller.MusicByList)
	//音乐ID找数据
	r.GET("/MusicByIds", controller.MusicByIds)
	//音乐搜索
	r.GET("/MusicByTitleSearch",controller.MusicBySearchTitle)
	//标记喜欢
	r.POST("/MusicLikeByJoin", controller.CheckToken, controller.MusicLikeByJoin)
	//取消喜欢
	r.POST("/MusicLikeByExit", controller.CheckToken, controller.MusicLikeByExit)
	//喜欢列表
	r.GET("/MusicLikeByList", controller.CheckToken, controller.MusicLikeByList)
	//用户信息多个
	r.GET("/UserByInfos", controller.CheckToken, controller.UserByInfos)


	//总后台接口---------------------------------------------------------------------------------------------------------+
	//管理员登录
	r.POST("/Admin/AdminByLoginToUsername", controller_admin.AdminByLoginToUsername)

	//歌曲作者列表
	r.GET("/Admin/MusicByAuthorList",controller_admin.MusicByAuthorList)
	//歌曲作者添加
	r.POST("/Admin/MusicByAuthorAdd",controller_admin.MusicByAuthorAdd)
	//歌曲作者编辑
	r.POST("/Admin/MusicByAuthorEdit",controller_admin.MusicByAuthorEdit)
	//歌曲作者删除
	r.POST("/Admin/MusicByAuthorDel",controller_admin.MusicByAuthorDel)
	//乐队列表
	r.GET("/Admin/MusicByTeamList",controller_admin.MusicByTeamList)
	//乐队添加
	r.POST("/Admin/MusicByTeamAdd",controller_admin.MusicByTeamAdd)
	//乐队编辑
	r.POST("/Admin/MusicByTeamEdit",controller_admin.MusicByTeamEdit)
	//乐队删除
	r.POST("/Admin/MusicByTeamDel",controller_admin.MusicByTeamDel)
	//歌曲添加
	r.POST("/Admin/MusicByMusicAdd", controller_admin.MusicByMusicAdd)


	//公共接口-----------------------------------------------------------------------------------------------------------+

	//图片上传
	r.POST("/PictureUpLoading", common.ByPictureUpLoading)
	//文件下载
	r.GET("/download/", common.ByDownLoad)
	//访问public下面的文件
	r.GET("/static/", common.ByPublic)
	//服务器关闭接口
	r.POST("/configByOver", func(j *job.Job) {
		if j.Input["password"] == "init0" {
			r.ServerClose <- 1
			j.JsonSuccess(nil, "操作成功")
			return
		}
		j.JsonError(nil, "密码错误")
	})
	//默认接口
	r.GET("/", func(j *job.Job) {
		j.JsonError(nil, "接口不存在")
	})
	r.POST("/", func(j *job.Job) {
		j.JsonError(nil, "接口不存在")
	})
}
